POV-Ray : Newsgroups : povray.newusers : Two meanings of x? : Two meanings of x? Server Time
30 Jul 2024 22:24:50 EDT (-0400)
  Two meanings of x?  
From: Dave Matthews
Date: 5 Aug 2003 14:45:01
Message: <web.3f2ff7b7cfc89a807196f5900@news.povray.org>
I'm not exactly a new user, but this is definitely a basic new-user type
question, and the answer is probably in the manual, but I have been pouring
over it off and on for a few months and am still confused on this basic
point.  Please be kind in your response.

In section 6.1.4.5, we learn that x, y, z, t, u, and v are constants, i.e.,
standard unit basis vectors.  x = <1, 0, 0>, etc.

Yet, inside a function, x is not a constant, but a variable, i.e. the
x-component of "something."  I can define a function in an isosurface with
function { y - x*x + z*z} and x, y and z are definitely not the unit basis
vectors in this interpretation.  In fact, I can usually get by with just
thinking of them as the co-ordinates of a point in 3D space.

Here's where my problem comes in.  Suppose I want to define a multi-rule
function:

In regular math, if x, y, and z were just points in space, I could say:

function{ #if (x < 0 ) whatever },

but, of course, in POVRay, I get an error, since here x is interpreted as
the standard unit basis vector <1, 0, 0>, even though in the function
description that follows, x is evaluated as a float variable (I'm not a
programmer, so "float variable" is probably the wrong term, but I hope you
know what I mean.)

So I guess my question has three parts:

1.  If, inside a function, x, y and z are components of some vector, what's
the name of the vector?  (So I can do a myvector.x in the #if statement.)

2.  If they aren't, and I'm all messed up, can you straighten me out, or
point me to the place in the manual that explains this (since these things
are all usually explained somewhere in the manual, but I'm often blind when
looking)?

3.  If questions #1 and #2 make no sense, could someone tell me how to
reference x, y and z with #if statements inside a function, and maybe when
I see the correct syntax I'll figure out what's wrong with my thinking.
Like, how would I make a function that gives me, for example, x*x + y*y +
z*z - 4 if sin(x + y) < z and x*x - y*y otherwise (just to pull an example
out of thin air.)

I know getting an inane question like this, after all the work you put into
the manual, must be frustrating, but I'm at a loss here, and I need
straightening out.

Thanks

Dave Matthews


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.